package gewu.suleju.dao.iml;

import gewu.suleju.model.pojo.HouseInfor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface IHouseInforDao extends JpaRepository<HouseInfor,Integer> {
    Page<HouseInfor> findAll(Pageable pageable);//房子分页
    HouseInfor findByIsPic(Integer isPic);
    @Transactional
    @Modifying
    @Query(value="update house_infor set is_pic = 0 where id = ?1",nativeQuery=true)//为0则有图片了
    void updateIsPic(Integer id);
    HouseInfor findById(int id);
    List<HouseInfor> findHouseInforsByIdIn(List<Integer> houseIdList);
    List<HouseInfor>   findHouseInforsByUserId(Integer userid);
    HouseInfor findHouseInforById(Integer id);
}
